﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class HangHoaBUS
    {
        #region 1.Retrieving
        public static List<HangHoaDTO> SeleltAllHangHoa()
        {
            return HangHoaDAO.SelectAllHangHoa();
        }
        public static bool CheckMaHangHoaExits(string maMatHang)
        {
            return HangHoaDAO.CheckMaHangHoaExits(maMatHang);
        }
        public static List<HangHoaVaDonViTinhDTO> SelectKetBangHangHoaDonViTinhAll()
        {
            return HangHoaDAO.SelectAllHangHoaAndDonViTinh();
        }
        public static List<HangHoaDTO> SelectHangHoaByID(string maHangHoa)
        {
            return HangHoaDAO.SelectHangHoaByID(maHangHoa);
        }
        #endregion
        #region 2.Deleting
        public static bool DeleteHangHoa(string maMatHang)
        {
            if (!HangHoaDAO.CheckMaHangHoaExits(maMatHang))
            {
                return false;
            }
            return HangHoaDAO.DeleteHangHoa(maMatHang);
        }

        #endregion
        #region 3.Updating
        public static bool UpdateHangHoa(HangHoaDTO hangHoa)
        {
            if (!HangHoaDAO.CheckMaHangHoaExits(hangHoa.MaMatHang))
            {
                return false;
            }
            return HangHoaDAO.UpdateHangHoa(hangHoa);
        }
        #endregion
        #region 4.Inserting
        public static bool InsertHangHoa(HangHoaDTO hangHoa)
        {
            if (HangHoaDAO.CheckMaHangHoaExits(hangHoa.MaMatHang))
            {
                return false;
            }
            return HangHoaDAO.InsertHangHoa(hangHoa);
        }

        #endregion
    }
}
